app.controller("itemCatController",function($scope,$controller,itemCatService){
    $scope.list = [];
    $scope.grade = 1;

    $scope.entity_1 = {};
    $scope.entity_2 = {};

    $scope.setGrade = function(num){
        $scope.grade = num;
    }

    $scope.selectList = function(entity){
        if($scope.grade==1){
            $scope.entity_1 = {};
            $scope.entity_2 = {};
        }else if($scope.grade==2){
            $scope.entity_1 = entity;
            $scope.entity_2 = {};
        }else {
            $scope.entity_2 = entity;
        }
        $scope.findByParentId(entity.id);
    }


    $scope.findByParentId = function(parentId){
        itemCatService.findByParentId(parentId).then(function(result){
            $scope.list = result.data;
        })
    }
});